Custom Control - FilterListCode Walkthrough Example

Custom Control - Filtered Dropdown Selection List Walkthrough Example

This example demonstrates how to create a filtered dropdown selection list (FilterListCode) which, when a user starts typing, only displays the relevant options.

Create a project

We first need a rulebase that uses a dropdown list to collect an attribute value during an investigation.

Create the rulebase

  1. Create a new project inside Oracle Policy Modeling.
  2. Add a new properties file.
  3. Open it and add the text attribute "the person's profession" to the global entity.
  4. Create a new Word rule document and open it.
  5. Add the following rule to the Word document:

    the person is eligible if

        the person's profession = "IT"

  6. Compile the Word document and fix any errors.
  7. Close the word document.
  8. Open the properties file. Right click in the Attributes area and Generate Public Names.
  9. Rename the automatically generated public name for "the person is eligible" to "person_eligible".

Create the screens

  1. Inside the project, create a new screens file and open it.
  2. Create a question screen to collect "the person's profession" as a dropdown list.
  3. Create a new attribute input for "the person's profession". Change the 'Input Type' to a 'Drop Down List', and specify selection items to add entries for various professions to the dropdown list.
  4. Create a summary screen for "the person is eligible".
  5. Build & debug to ensure the rulebase is working correctly. If there are any errors, fix them before proceeding with the steps below.

Modify the Velocity templates

We now modify the Velocity templates to add the filtering functionality. The filtered dropdown list (also called a combo-box) is created by using the existing Web Determinations template DropdownSelection.vm found under templates/investigation.

Note: Combo box search functionality is unsupported in Opera browsers and hence disabled.

 

The effect is achieved by using an input field along with the dropdown list. We show or hide the dropdown list based on where the focus is on the page. The user can use the collapse and expand icons to access the dropdown list from the input field; for example, if a user is typing in the input text field, then the dropdown list is shown. This list shown will only have the options that match the text in the input field. If the user clicks anywhere else other than the expand/collapse icons, the dropdown list will be made invisible.

The files can be found under examples\web-determinations\filtered-list-control\src\templates. The customization consists of the following files:

File

Description

templates/investigation/Dropdown-selection.vm Contains the layout of the input text field and the dropdown list that make up a combo-box.
templates/javascript/comboBox.js Contains the code for the combo-box effect.
templates/javascript/onClick.vm

Contains the code for handling the visibility of the dropdown selection based on where the user clicks on the page.

templates/javascript/filter.js Contains the code for filtering a list of options based on some text.
templates/question_screen.vm

Modified to include the javascript files.

Run the example

To run the example, do the following:

  1. Use the FilterListExample project under examples\rulebases\source.
  2. Open the project in Oracle Policy Modeling.
  3. Build and Debug with screens; this creates a Release directory.
  4. Copy the files from:

    examples\web-determinations\filtered-list-control\src\templates
    to:
    FilterListExample\Release\web-determinations\WEB-INF\classes\templates.

  5. Build and (Debug or Run) with screens.